package com.nov.multidatasource.api;

import cn.hutool.core.collection.CollUtil;
import io.minio.MinioClient;
import io.minio.StatObjectArgs;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;

public class Test {

    public static String endpoint = "https://oss.ansteel.cn:443";
    public static String accessKey = "CNHv5HCwe0e12kzjoB8Y";
    public static String secretKey = "fsimagebucket1DkMyzf0sWabnpOyP9iTyb";
    public static String bucket = "fs-image-bucket-prd";

    public static void main(String[] args) throws IOException {
//        MinioClient client = MinioClient.builder()
//                .endpoint(endpoint)
//                .credentials(accessKey, secretKey)
//                .build();
//        boolean b = fileExists(client, bucket, "images/2024/06/20240624/80401202406240000015619804015619/进项票夹系统发票附件/合同1.jpg");
//        System.out.println(b);
//        String a = null;
//        ArrayList<Object> objects = CollUtil.newArrayList(a);
//        System.out.println("hhh");
        String hj = "测试065-16728771-643";
        System.out.println(URLEncoder.encode(hj, "UTF-8"));
    }

    public static boolean fileExists(MinioClient minioClient, String bucketName, String objectId) {

        try {
            TimeUnit.MILLISECONDS.sleep(200L);
            minioClient.statObject(
                    StatObjectArgs.builder().bucket(bucketName).object(objectId).build()
            );
        } catch (Exception e) {
            return false;
        }
        return true;

    }
}
